package com.zmn.oms.manager.config;

// import com.google.common.collect.Lists;
// import java.net.InetAddress;
// import java.net.UnknownHostException;
// import java.util.List;
// import org.elasticsearch.client.transport.TransportClient;
// import org.elasticsearch.common.settings.Settings;
// import org.elasticsearch.common.transport.InetSocketTransportAddress;
// import org.elasticsearch.common.transport.TransportAddress;
// import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient;
// import org.springframework.beans.factory.annotation.Value;
// import org.springframework.boot.context.properties.ConfigurationProperties;
// import org.springframework.context.annotation.Bean;
// import org.springframework.context.annotation.Configuration;
// import org.springframework.stereotype.Component;

// /**
//  * 类描述：es配置
//  *
//  * @author lujia
//  * @date 2019/01/04 11:03
//  */
// @Configuration
// @Component
// @ConfigurationProperties(prefix = "spring.data.elasticsearch")
// public class ElasticConfig {
//
//     @Value("${spring.data.elasticsearch.cluster-name}")
//     private String clusterName;
//
//     @Value("${spring.data.elasticsearch.xpack-security-user}")
//     private String xpackSecurityUser;
//
//     @Value("${spring.data.elasticsearch.cluster-nodes}")
//     private String clusterNodes;
//
//     @Bean
//     public TransportClient transportClient() throws UnknownHostException {
//         List<InetSocketTransportAddress> addressList = Lists.newArrayList();
//         String[] nodes = clusterNodes.split(",");
//         for (String node : nodes) {
//             String[] nodeArr = node.split(":");
//             addressList.add(new InetSocketTransportAddress(InetAddress.getByName(nodeArr[0]), Integer.valueOf(nodeArr[1])));
//         }
//         TransportAddress[] nodeArr = addressList.toArray(new InetSocketTransportAddress[addressList.size()]);
//         TransportClient client = new PreBuiltXPackTransportClient(Settings.builder()
//                 .put("cluster.name", clusterName)
//                 .put("client.transport.sniff", false)
// //                .put("xpack.security.transport.ssl.enabled", false)
//                 .put("xpack.security.user", xpackSecurityUser)
//                 .build())
//                 .addTransportAddresses(nodeArr);
//         return client;
//     }
// }
